import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:wy/pages/player/control_panel1.dart';
import 'package:wy/pages/player/control_panel2.dart';
import 'package:wy/pages/player/header.dart';
import 'package:wy/pages/player/play_info.dart';
import 'package:wy/pages/player/play_list.dart';
import 'package:wy/pages/player/player_inner.dart';
import 'package:wy/pages/player/progress.dart';
import 'package:wy/utils/player_state.dart';
import 'package:wy/utils/screen_util.dart';

class HPlayer extends StatelessWidget {
  const HPlayer({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final screen = Screen(context);
    final args = ModalRoute.of(context).settings.arguments as Map;
    final playState = PlayState.of(context);
    // print(playState);

    return Scaffold(
      body: Stack(
        children: [
          Image.asset('assets/images/tmp_cover_7.jpg',
              height: screen.height, width: screen.width, fit: BoxFit.fill),
          Positioned.fill(
              child: BackdropFilter(
                  filter: ImageFilter.blur(sigmaX: 60, sigmaY: 60),
                  child: Container(
                    color: Colors.black.withOpacity(0.2), //主要是要这个透明度
                  ))),
          Container(
            width: double.infinity,
            decoration: BoxDecoration(
              color: Color(0x99000000),
            ),
            padding: EdgeInsets.only(top: screen.top),
            child: Column(
              children: [
                Hheader(),
                HPlayerInner(playing: false),
              ],
            ),
          ),
          Positioned(
              bottom: 0,
              child: Container(
                width: screen.width,
                child: Column(
                  children: [
                    HControlPanel1(
                      onDownload: () {},
                      onBell: () {},
                      onPlayInfo: () {
                        showPlayInfo(context);
                      },
                      onCommen: () {
                        Navigator.pushNamed(context, '/commen');
                      },
                    ),
                    HProgress(
                      current: playState.current,
                      total: playState.total,
                    ),
                    HControlPanel2(
                      playing: playState.playing,
                      onBackward: () {},
                      onPauseTap: () {
                        playState.player.pause();
                      },
                      onForward: () {},
                      onPlayTap: () {
                        playState.player.play(
                            'https://luan.xyz/files/audio/nasa_on_a_mission.mp3');
                      },
                      onPlaylist: () {
                        showPlayList(context);
                      },
                    ),
                  ],
                ),
              ))
        ],
      ),
    );
  }
}
